package com.itheima.day04;

public class Tist {
    public static void main(String[] args) {
        int[] arr = {1, 1, 2, 2, 3, 3};

        int count = printCount(arr);
        System.out.println(count);
        int[] ints = printInt(arr);
        for (int i = 0; i < ints.length; i++) {
            if(ints[i]==0){
                continue;
            }else {
                System.out.print(ints[i] + " ");
            }
        }

    }
//求相同的个数
    public static int printCount(int[] arr) {
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            for (int j = i; j < arr.length - 1; j++) {
                if (arr[i] == arr[j + 1]) {
                    count++;
                }
            }
        }



        return count;
    }
//打印重复数组的个数
    public static int[] printInt(int[] arr) {
        int[] arr1 = new int[arr.length];

        for (int i = 0; i < arr.length; i++) {
            for (int j = i; j < arr.length - 1; j++) {
                if (arr[i] == arr[j + 1]) {
                    arr1[i] = arr[i];
                }
            }
        }
        return arr1;
    }


    //输出数组元素个数
    public static void printArray(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + ", ");
        }
    }
}

